<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // class(类)的继承
        class phone {
            // 构造方法
            constructor(brand, price) {
                this.brand = brand;
                this.price = price;
            }

            // 父类的成员属性
            call() {
                console.log("我可以打电话");
            }
        }

        // 子类继承父类的属性和方法
        class smartPhone extends phone {
            // 构造方法
            constructor(brand, price, color, size) {
                super(brand, price);
                this.color = color;
                this.size = size;
            }
            // 子类特有的属性
            photo() {
                console.log("拍照");
            }
            playGame() {
                console.log("我可以打游戏");
            }
        }

        const xiaomi = new smartPhone("xiaomi", 1999, "red", "4.7inch");
        console.log(xiaomi);
    </script>
</body>

</html>